const ERROR_CODE = require('../errorCode');

function ctxBodyFormatter(res) {
  if (Object.values(ERROR_CODE).includes(res)) {
    return {
      status: 200,
      body: {
        code: 0,
        msg: res
      }
    };
  } else {
    return {
      status: 200,
      body: {
        code: 1,
        data: res
      }
    };
  }
}

module.exports = {
  ctxBodyFormatter
};
